package cn.mavor.day0903;

public class biggestnum {
    public static void main(String[] args) {
        int[] numbers = {1, 20, 4, 21, 45};
        int[] result = findMaxAndIndex(numbers);
        System.out.println("最大数为：" + result[0] + "，位置是：" + result[1]);
    }

    public static int[] findMaxAndIndex(int[] arr) {
        int max = arr[0];
        int index = 0;

        for (int i = 1; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i];
                index = i;
            }
        }

        return new int[]{max, index};
    }
}
